<template>
  <div class="wft-w-h-100">
    <van-uploader
      v-model="files"
      :name="attrs.name"
      :disabled="attrs.disabled"
      :max-count="attrs.maxCount"
      :deletable="attrs.deletable"
      :preview-image="attrs.previewImage"
      :preview-full-image="attrs.previewFullImage"
      :multiple="attrs.multiple"
    />
  </div>
</template>
<script setup lang='ts'>
import { useAttrs } from 'generator/hooks'
import { computed, ref, watch } from 'vue';

const props = defineProps<{
  panelJson: TPanel
  curComp: TComp
}>()

const attrs = useAttrs(props.curComp.attrs)

const files = ref([])

const fileList = computed(() => {
  const defauleValue: any[] = []
  if(!attrs.value.fileList) return defauleValue
  const dataInfo = props.panelJson.data.find(item => item.variable == attrs.value.fileList)
  return dataInfo?.value ?? defauleValue
})

watch(() => fileList, () => {
  files.value = fileList.value
}, { deep: true, immediate: true })
</script>
<style scoped>
.wft-w-h-100 {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>